<?php

class Core {

	private $application;
	private $shortUrl = '';

	public function __construct(&$application) {
		$this->application = &$application;
		if (isset($_SERVER['PATH_INFO'])) {
			$this->segments = explode('/', $_SERVER['PATH_INFO']);
			$this->shortUrl = $this->segments[1];
		}
		$this->application->shortUrl = $this->shortUrl;
	}

	public function main() {
		if ($this->shortUrl == '')
			$this->application->index();
		else if ($this->shortUrl[0] == '@')
			$this->application->api();
		else
			$this->application->shorten();
	}

}

/* end of core.php */